package com.xxx.test;

import com.xxx.DAO.booksDao;
import com.xxx.entity.Book;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

@WebServlet("/showBook")
public class showBook extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        this.doPost(request, response);
    }

    @Override
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        String userId = request.getSession().getAttribute("id").toString();
        String bName=request.getParameter("bName");
        booksDao dao=new booksDao();
        Book book=dao.findBook(bName,userId);
        request.setAttribute("book",book);
        request.getRequestDispatcher("红楼梦.jsp").forward(request,response);
    }
}
